#include "IntroWizard.h"
#include "ui_IntroWizard.h"

#include <QMessageBox>
#include <QSettings>

IntroWizard::IntroWizard(QWidget *parent) :
    QWizard(parent),
    ui(new Ui::IntroWizard)
{
    ui->setupUi(this);
    setPixmap(QWizard::WatermarkPixmap, QPixmap(":/wizard.png"));
}

IntroWizard::~IntroWizard()
{
    delete ui;
}

void IntroWizard::accept()
{
    QString username = field("username").toString();
    QString ptogzCode = field("ptogzCode").toString();
    QString aavsoCode = field("aavsoCode").toString();

    bool downloadValidationFile = field("downloadValidationFile").toBool();
    bool aavsoRss = field("aavsoRss").toBool();
    bool enableGcvs = field("enableGcvs").toBool();

    // zapis do rejestru
    QSettings settings;
    settings.setValue("user/userName", username);
    settings.setValue("user/ptogzCode", ptogzCode);
    settings.setValue("user/aavsoCode", aavsoCode);

    settings.setValue("network/enableAavsoRss", aavsoRss);
    settings.setValue("network/aavsoFeedUrl", "http://aavso.org/feed.xml");
    settings.setValue("network/aavsoQuickLookUrl", "http://www.aavso.org/cgi-bin/newql.pl?name=%1&output=html");
    settings.setValue("network/downloadValidationFile", downloadValidationFile);
    settings.setValue("network/canDownloadFromGcvs", enableGcvs);
    settings.setValue("network/gcvsUrl", "http://www.sai.msu.su/groups/cluster/gcvs/cgi-bin/search.cgi?search=%1");

    QWizard::accept();
}
